package com.design.marketPrj.application.controller.trade;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.design.marketPrj.application.controller.BaseController;
import com.design.marketPrj.application.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/trade")
public class TradeController extends BaseController {

    @Autowired
    TradeService tradeService;

    @RequestMapping("/buy")
    @ResponseBody
    public JSONObject buy(String code,String amount2buy){
        JSONObject jsonObject = tradeService.buy(code,amount2buy,getUser());

        return jsonObject;
    }

    @RequestMapping("/sell")
    @ResponseBody
    public JSONObject userProductSell(String code,String amountToSell){
        JSONObject jsonObject = tradeService.sell(code,amountToSell,getUser());

        return jsonObject;
    }

}
